package com.atguigu.gmall.seckill.rpc;

import com.atguigu.gmall.common.result.Result;
import com.atguigu.gmall.model.order.vo.OrderConfirmVo;
import com.atguigu.gmall.model.seckill.entity.SeckillGoods;
import com.atguigu.gmall.seckill.biz.SeckillBizService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/api/inner/seckill")
public class SeckillRpcController {

    @Autowired
    SeckillBizService seckillBizService;




    @GetMapping("/getSecKillGoods")
    public Result<List<SeckillGoods>> getSecKillGoods() {
        List<SeckillGoods> seckillGoods = seckillBizService.getSecKillGoods();
        return Result.ok(seckillGoods);
    }

    @GetMapping("/detail/{skuId}")
    public Result<SeckillGoods> getDetail(@PathVariable Long skuId) {
        SeckillGoods detail = seckillBizService.getDetail(skuId);
        return Result.ok(detail);
    }

    @GetMapping("/getSeckillOrder/{skuIdStr}")
    public Result<OrderConfirmVo> getSeckillOrder(@PathVariable String skuIdStr) {
        OrderConfirmVo orderConfirmVo = seckillBizService.geConfireOrder(skuIdStr);
        return Result.ok(orderConfirmVo);
    }


}
